package com.example.b_308.myapplication.view.user.register.createdepartment;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import com.example.b_308.myapplication.R;
import com.example.b_308.myapplication.model.Department;
import com.example.b_308.myapplication.view.main.Base.BaseLvAdapter;

import java.util.List;

/**
 * Created by B-308 on 2017/11/22.
 */
public class RegisterAdapter extends BaseLvAdapter implements View.OnClickListener {
    List<Department> departmentList;
    LayoutInflater inflater;
    Context context;

    public void notifyChango(List<Department> departmentList){
        this.departmentList = departmentList;
        notifyDataSetChanged();

    }

    public RegisterAdapter(List<Department> departmentList, Context context) {
        this.departmentList = departmentList;
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return departmentList.size();
    }

    @Override
    public Department getItem(int position) {
        return departmentList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if(null == convertView){
            convertView = inflater.inflate(R.layout.activity_update_department,null,false);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder) convertView.getTag();
        }
        convertView.setOnClickListener(this);
        return convertView;
    }

    @Override
    public void onClick(View v) {

    }

    class ViewHolder{
        View contentView;
        EditText et_create_department;

        public ViewHolder(View contentView){
            this.contentView = contentView;
            et_create_department = (EditText) contentView.findViewById(R.id.et_create_department);
        }
    }
}
